//
//  CollectViewController.m
//  好听-1
//
//  Created by luojin on 15/4/13.
//  Copyright (c) 2015年 MyCompany. All rights reserved.
//

#import "CollectViewController.h"
#import "SpecialTopicViewController.h"
#import "FMViewController.h"
#import "SquareViewController.h"
#import "ActiveViewController.h"

#define SCREEN_X 375
#define SCREEN_Y 667

@interface CollectViewController ()

@end

@implementation CollectViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    [self.view setBackgroundColor:[UIColor whiteColor]];
    
    [self creatSegementControl];
//     self.seg.selectedSegmentIndex = 0;
}

- (void)creatSegementControl
{
    NSMutableArray *segArray = [NSMutableArray array];
    
    [segArray addObject:[UIImage imageNamed:@"square"]];
    [segArray addObject:[UIImage imageNamed:@"spetial topic"]];
    [segArray addObject:[UIImage imageNamed:@"active"]];
    [segArray addObject:[UIImage imageNamed:@"FM1"]];
    
    _seg = [[UISegmentedControl alloc] initWithItems:segArray];
    _seg.frame = CGRectMake(0, 0, self.view.frame.size.width, 40);
    _seg.tintColor = [UIColor colorWithRed:45 / 255 green:222 / 255 blue:456 / 255 alpha:0.5];
    [_seg addTarget:self action:@selector(popToView:) forControlEvents:UIControlEventValueChanged];
   
    SquareViewController *square = [[SquareViewController alloc] init];
    
    [self.view addSubview:square.view];
    square.view.frame = CGRectMake(0, 40, SCREEN_X, SCREEN_Y);
    
    [self.view addSubview:_seg];
    [_seg release];
    
    [square release];
}

- (void)popToView:(id)sender
{
    SpecialTopicViewController *special = [[SpecialTopicViewController alloc] init];
    ActiveViewController *active = [[ActiveViewController alloc] init];
    SquareViewController *square = [[SquareViewController alloc] init];
    FMViewController *fm = [[FMViewController alloc] init];

    switch (_seg.selectedSegmentIndex) {
        case 0:
            [self.view addSubview:square.view];
            square.view.frame = CGRectMake(0, 40, SCREEN_X, SCREEN_Y);
            break;
        case 1:
            [self.view addSubview:special.view];
            special.view.frame = CGRectMake(0, 40, SCREEN_X, SCREEN_Y);
            break;
        case 2:
            [self.view addSubview:active.view];
            active.view.frame = CGRectMake(0, 40, SCREEN_X, SCREEN_Y);
            break;
        case 3:
            [self.view addSubview:fm.view];
            fm.view.frame = CGRectMake(0, 40, SCREEN_X, SCREEN_Y);
            break;
            
        default:
            break;
    }
   
//    [square release];
//    [special release];
//    [active release];
//    [fm release];
}

@end
